package cn.csdj.sism.web;


import cn.csdj.sism.pojo.Permission;

import cn.csdj.sism.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李加
 * 2023/4/10
 */
@CrossOrigin
@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    /**
     * 查询全部
     * @return
     */
    @GetMapping
    public List<Permission> selectPerAll(){
        return permissionService.selectPerAll();
    }
    /**
     * 通过Id查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Permission selectPerById(@PathVariable Integer id){
        return permissionService.selectPerById(id);
    }
    /**
     * 添加
     * @param permission
     */
    @PostMapping
    public void insertPer(@RequestBody Permission permission){
        permissionService.insertPer(permission);
    }

    /**
     * 修改
     * @param permission
     */
    @PutMapping
    public void updatePer(@RequestBody Permission permission){
        permissionService.updatePer(permission);
    }

    /**
     * 删除
     * @param id
     */
    @DeleteMapping
    public void delectPer(@PathVariable Integer id){
        permissionService.delectPerById(id);
    }
}
